package com.ctgu.蓝桥杯真题.B组2019;

import java.io.*;
import java.util.*;

/**
 * @author: Backdiy
 * @data: 2021/4/11 16:32
 * @desc:
 */
public class H人物相关性分析 {

    public static void main(String[] args) throws IOException {
        PrintWriter printWriter = new PrintWriter(new BufferedWriter(new OutputStreamWriter(System.out)));
        BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(System.in));
        int k = Integer.parseInt(bufferedReader.readLine());
        String s = bufferedReader.readLine();
        int ans = 0;
        String[] word = s.split("[^a-zA-Z]");
        int sum = 0, cnt = 0;
        int[] b = new int[s.length()];
        int[] ind = new int[s.length()];
        for (int i = 0; i < word.length; i++) {
            if (word[i].equals("Alice")) {
                int x = sum - k - 3;
                int y = sum + k + 5;
                if (x < 0) x = 0;
                if (y < s.length()) ind[y]--;
                ind[x]++;
            }
            if (word[i].equals("Bob")) {
                b[cnt++] = sum;
            }
            sum += word[i].length() + 1;
        }
        for (int i = 1; i < ind.length; i++) {
            ind[i] = ind[i - 1] + ind[i];
        }
        for (int i = 0; i < cnt; i++) {
            ans += ind[b[i]];
        }
        printWriter.println(ans);
        printWriter.flush();
    }
}
